﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var keyValue = $.request("keyValue");
    var moduleId = $.request("moduleid");
    var ParentUrl = $.request("ParentUrl");
    $(function () {
        initControl();
        if (!!keyValue) {
            $.ajax({
                url: "/SystemManage/SysModuleAuthorize/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                }
            });
        } else {
            // $("#SortCode").val("10");
        }
    });
    function initControl() {
        $("#Location").select2({ minimumResultsForSearch: -1 });
        $("#ParentId").bindSelect({
            url: "/SystemManage/SysModuleAuthorize/GetTreeSelectJson",
            param: { moduleId: moduleId }
        });
    }
    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        var postData = $("#form1").formSerialize();
        postData["ModuleId"] = moduleId;
        var submitUrl = "Insert";
        if (!!keyValue) {
            submitUrl = "Update";
        }
        $.submitForm({
            url: "/SystemManage/SysModuleAuthorize/" + submitUrl + "?keyValue=" + keyValue,
            // param: $("#form1").formSerialize(),
            param: postData,
            success: function () {
                if (ParentUrl === "") {
                    $.currentWindow().$("#gridList").trigger("reloadGrid");
                } else {
                    top.frames[ParentUrl].$("#gridList").trigger("reloadGrid");
                }
            }
        });


        return false;
    };
</script>
<form id="form1">
    <div style="padding-top: 30px; margin-right: 30px;">
        <table class="form">
            <tr>
                <th class="formTitle">名称</th>
                <td class="formValue Value">
                    <input id="FullName" name="FullName" type="text" class="form-control required" placeholder="请输入名称" />
                </td>
                <th class="formTitle">编号</th>
                <td class="formValue Value">
                    <input id="EnCode" name="EnCode" type="text" class="form-control" placeholder="前台验证是,需要和按钮的id关联" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">上级</th>
                <td class="formValue Value">
                    <select id="ParentId" name="Parentid" class="form-control required">
                        <option value="0">父节点</option>
                    </select>
                </td>
                <th class="formTitle">作用</th>
                <td class="formValue Value">
                    <select id="Location" name="Location" class="form-control required">
                        <option value="1">前台初始</option>
                        <option value="2">前台选中</option>
                        <option value="3">后台验证</option>
                        <option value="4">前后同用</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th class="formTitle">事件</th>
                <td class="formValue Value">
                    <input id="JsEvent" name="JsEvent" type="text" class="form-control" placeholder="前台验证是,需要和按钮的事件关联" />
                </td>
                <th class="formTitle">连接</th>
                <td class="formValue Value">
                    <input id="UrlAddress" name="UrlAddress" type="text" class="form-control" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">图标</th>
                <td class="formValue Value">
                    <div class="input-group">
                        <input id="Icon" name="Icon" type="text" class="form-control">
                        <span class="input-group-btn">
                            <a class="btn  btn-primary"><i class="fa fa-ellipsis-h"></i></a>
                        </span>
                    </div>
                </td>
                <th></th>
                <td></td>
                @*<th class="formTitle">排序</th>
                    <td class="formValue Value">
                        <input id="SortCode" name="SortCode" type="text" class="form-control required" />
                    </td>*@
            </tr>
            <tr>
                <th class="formTitle" style="height: 35px;">选项</th>
                <td class="formValue Value" colspan="3" style="padding-top: 1px;">
                    <div class="ckbox">
                        <input id="EnabledMark" name="EnabledMark" type="checkbox" checked="checked"><label for="EnabledMark">有效</label>
                    </div>

                    @*<div class="ckbox">
                            <input id="Split" name="split" type="checkbox"><label for="Split">分开线</label>
                        </div>
                        <div class="ckbox">
                            <input id="IsPublic" name="IsPublic" type="checkbox"><label for="IsPublic">公共</label>
                        </div>

                        <div class="ckbox">
                            <input id="AllowEdit" name="AllowEdit" type="checkbox"><label for="AllowEdit">允许编辑</label>
                        </div>
                        <div class="ckbox">
                            <input id="AllowDelete" name="AllowDelete" type="checkbox"><label for="AllowDelete">允许删除</label>
                        </div>*@
                </td>
            </tr>
            <tr>
                <th class="formTitle" valign="top" style="padding-top: 5px;">
                    描述
                </th>
                <td class="formValue Value" colspan="3">
                    <textarea id="Description" name="Description" class="form-control" style="height: 100px;"></textarea>
                </td>
            </tr>
        </table>
    </div>
</form>
